Skip to content

feat(rsa): in-place RSA update + corrected learning-reset warning (split 4/4 of #34)#53

Open
illia-sapryga wants to merge 2 commits into
kLOsk:mainfrom
illia-sapryga:feat/rsa-inplace-update
Open

feat(rsa): in-place RSA update + corrected learning-reset warning (split 4/4 of #34)#53
illia-sapryga wants to merge 2 commits into
kLOsk:mainfrom
illia-sapryga:feat/rsa-inplace-update

Conversation

@illia-sapryga

Copy link
Copy Markdown
Contributor

Split 4/4 of #34 — RSA in-place update (folds in #42)

Final split. Independent (off main), registers only its own tool.

Refactor + tool

  • Extracted a shared _validate_rsa_assets(headlines, descriptions, enforce_headline_count=True, enforce_description_count=True) from _validate_rsa. draft_responsive_search_ad keeps both enforce flags on; update_responsive_search_ad sets enforce_*_count=bool(list_provided) so it only gates the list(s) actually being replaced.
  • New update_responsive_search_ad — in-place mutate of headlines / descriptions / final_url / path1 / path2 (+ clear_path1/clear_path2).
  • _apply_update_rsaAdService.ad_path (plain ad ID), sparse FieldMask (only changed paths), list-replace headlines/descriptions with pin handling. (These are the mechanics you reviewed as correct.)

The fix you asked for — corrected the inverted claim

The #42 version claimed the in-place edit avoided a learning reset. That's backwards. Corrected everywhere (impl + server + apply docstrings), and added a preview warning that fires only when headlines/descriptions are actually being replaced:

Replacing headlines/descriptions is NOT a free in-place edit. Even though the ad keeps its ID, Google treats the creative as new: this resets the ad's asset-combination learning and wipes its performance history, and the ad is sent back through policy review before it can serve again. Only replace headlines/descriptions when the copy genuinely needs to change — for URL or display-path tweaks these effects do not apply.

TestLearningResetWarning proves it's present for headlines-replaced / descriptions-replaced / headlines+URL-mixed, and absent for URL-only, path-only, and clear-path-only edits.

v0.12 compliance

  • current_config() in the wrapper (stale-_config grep guard passes).
  • Added a _StrOrDictListOpt coercion alias so headlines/descriptions accept plain strings or {text, pinned_field} dicts while being optional.
  • Dispatch entry wired; handler (client, cid, changes); tests use set_plan_store(InMemoryPlanStore()).

Tests & hygiene

  • 481 passing — the 60 fake-client tests carried over + 6 warning tests.
  • PII scrubbed — example.com URLs, generic retail copy, no real client data.

This completes the four-way split of #34: (a) #50, (b) #51, (c) #52, (d) here. #42 and #43 can be closed in favor of these — say the word if you'd rather keep them open for reference.

https://claude.ai/code/session_01FKcPiYrtXWtg4b7dnW4o5s

Pull the headline/description content validation (count, char limits,
pin-slot rules) out of _validate_rsa into a standalone
_validate_rsa_assets(headlines, descriptions, enforce_headline_count,
enforce_description_count). draft_responsive_search_ad's _validate_rsa
now delegates to it with both counts enforced.

The enforce flags let a caller validate only the list(s) it is actually
sending — needed by the upcoming in-place RSA update, where an omitted
headline or description list stays untouched on the live ad and must not
be gated on the 3-15 / 2-4 count.

Claude-Session: https://claude.ai/code/session_01FKcPiYrtXWtg4b7dnW4o5s
…ing-reset warning

Add update_responsive_search_ad: mutate an existing RSA's headlines,
descriptions, final_url, path1, or path2 in place via AdService.MutateAds
(the ad keeps its ID). Uses a sparse FieldMask carrying only the changed
field paths; headlines/descriptions are list-replace and validated through
the shared _validate_rsa_assets, enforcing the count only on the list being
sent. Registers the tool, adds _apply_update_rsa and the _execute_plan
dispatch entry.

CRITICAL correctness fix over the original kLOsk#42 framing: replacing an RSA's
headlines or descriptions is NOT a free in-place edit. Even though the ad
ID is preserved, Google treats the creative as new — it resets the ad's
asset-combination learning and performance history and re-triggers policy
review. The docstrings state this plainly (dropping the inverted 'no
learning-period reset' claim), and the preview attaches a prominent warning
whenever headlines/descriptions are replaced. URL/path-only edits do not
carry the warning, since they are genuine in-place changes.

Tests: full fake-client coverage (validation, plan construction, sparse
FieldMask apply, confirm_and_apply integration, headline/description
mutation) plus warning presence/absence assertions, and a server-level
runtime-config call-through. All data scrubbed to example.com / generic copy.

Claude-Session: https://claude.ai/code/session_01FKcPiYrtXWtg4b7dnW4o5s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant